package com.cxy.msclass;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TestController {
    @Autowired
    private DiscoveryClient discoveryClient;

    @GetMapping("test-discovery")
    public List<ServiceInstance> testDiscovery(){
        //到consul上查询指定微服务的所有实例
        return discoveryClient.getInstances("ms-user");
    }
}
